<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>News system v1</title>

<link rel="stylesheet" type="text/css" href="style.css">

</head>

<body>

<div id="exCenter">
     <div id="exHeader">
        <center><h1><a href="index.php">News system v1</a></h1></center>
    </div>
    <div id="exContent">
        <div id="exLeftColumn">
            <p>
            
            <?PHP
$con=mysqli_connect("localhost","root","","bd_news");
// Check connection
if (mysqli_connect_errno()) {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
}


$id_news = mysqli_real_escape_string($con, $_GET['id']);


$result = mysqli_query($con,"SELECT id_news, title, maintext, date, rating, id_user  FROM `news` WHERE id_news=$id_news ");



while($row = mysqli_fetch_array($result)) {
	echo '<div>';
	
	
	echo '<table>';

	echo '<tr>';
	echo '	<th width="750" colspan="3">';
	echo 		$row['title']." <em>(ID: ".$row['id_news'].")</em>";
	echo '	</th>';
	echo '</tr>';

	echo '<tr>';
	echo '	<td width="750" colspan="3">';
		echo '<center>';
		$resulttag = mysqli_query($con,"SELECT TAG FROM tags where ID_TAG = any (select ID_TAGS from news_tags where ID_NEWS = any (select ID_NEWS from news where id_NEWS = $id_news))");
		while($rowtag = mysqli_fetch_array($resulttag)) {
			echo "&#35".$rowtag['TAG'].", ";
		}	
		echo '</center>';

	echo '	</td>';
	echo '</tr>';
	

	echo '<tr>';
	echo '	<td width="750" colspan="3">';
	echo 		$row['maintext'];
	echo			'<br> <center><a href="index.php">Powrót do strony głównej</a>.</center>';
	echo '	</td>';
	echo '</tr>';
	
	echo '<tr>';
	echo '	<td >';
	echo 		'Dodano '.$row['date'];	
	echo '	</td>';
		
	echo '	<td>';
	echo 		'<img alt="minus" height="15" src="img/plus.png" width="15" /> ';
	echo 		$row['rating'];	
	echo 		' <img alt="minus" height="15" src="img/minus.png" width="15" />';
	echo '	</td>';
		
		

	$resultuser = mysqli_query($con,"SELECT nick FROM users WHERE id_user=".$row['id_user']);
	$rowus = mysqli_fetch_array($resultuser);
	
	echo '	<td>';
	echo 		'Przez <strong>'.$rowus['nick'].'</strong>';
	echo '	</td>';
	
	
	echo '</tr>';
	
	echo '</table>';

	
	
	
	echo '</div><br><br>';
}




mysqli_close($con);	
?>

            
            
            </p>
            
            
            
            
        </div>
        <div id="exRightColumn">
            <p>Popularne #hashtagi<br>
            	#hash , #doge , #informatyka
            	</p>
            
            <hr>
            
            <p>Wyszukaj tag<br>
            	<input name="search_tag" type="text" /><br>
				<input name="Button1" type="button" value="Szukaj" />
					</p>
            <hr>
            
            <p>Szukaj w treści<br>
            	<input name="search_tag" type="text" /><br>
				<input name="Button1" type="button" value="Szukaj" />
					</p>
            <hr>
            
            <p>Pokaż tylko z ocenami<br>            	
	            <select name="Select1">
					<option>Powyżej 0</option>
					<option>Poniżej 0</option>
					<option>Powyżej 100</option>
					<option>Poniżej 100</option>				
				</select><br>
				<input name="Button1" type="button" value="Szukaj" />
            					</p>
            <hr>
            <p>Zakres daty<br>
            	od <input name="date_from" type="text" /><br>
            	do <input name="date_to" type="text" />
				<input name="Button1" type="button" value="Szukaj" />

            					</p>
            
            
            
            
            
            
        </div>
        <div class="exClear"></div>
    </div>
    <div id="exFooter">	    
	    <center>
	        <p><a href="newsmyadm.php">admin © 2014 Basinsky</a></p>
	    </center>    
    </div>
</div>




</body>

</html>
